# Maintainer: christian rebischke <chris.rebischke@archlinux.org>

pkgname=git-credential-gopass
pkgver=1.14.9
pkgrel=1
pkgdesc="git-credentials helper for gopass"
arch=('loong64' 'x86_64')
url="https://github.com/gopasspw/git-credential-gopass"
license=('MIT')
depends=('glibc')
makedepends=('go')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/gopasspw/git-credential-gopass/archive/refs/tags/v${pkgver}.tar.gz")
sha512sums=('a81a6b34fa402abad7529d65f1d63fcbe6ccbbfa167ee24e06c4f9c2367c9ff93dd4b949d515606fe739d7ec0c0ee745ddc1816e8dd1e310aafc6abe4b63a0e6')
options=('!lto')

prepare(){
  cd ${pkgname}-${pkgver}
  sed -i 's|-gcflags="-trimpath=$(GOPATH)" -asmflags="-trimpath=$(GOPATH)"||' Makefile
  sed -i 's/install-completion//g' Makefile
}

build(){
  cd ${pkgname}-${pkgver}
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
  make
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" PREFIX="/usr" install
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
